/**
 * 
 */
package com.nba.common.utils;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.springframework.core.io.support.PropertiesLoaderUtils;


public class PropertiesLoaderUtil {

	/**
	 * 属性文件加载方法
	 * @param resourceName
	 * @return
	 * @throws IOException
	 */
	public static Properties loadAllProperties(String resourceName)
			throws Exception {
	    InputStream fis = ClassLoader.getSystemResourceAsStream(resourceName);
        Properties props = new Properties();
        props.load(fis);
        fis.close();
        return props;
	}
   
	static Properties properties;
    
	public static String getPropValue(String strKey) {
		if (null == properties) {
			try {
			    properties = loadAllProperties("system.properties");
			} catch (Exception e) {
				e.printStackTrace();
				return "";
			}
		}
		return properties.getProperty(strKey);
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
	    //System.out.println("C:" + File.separator + "tmp" + File.separator + "test.txt");
		System.out.println(PropertiesLoaderUtil.getPropValue("system.encoding"));
	}
}
